/*
 * @Descripttion:
 * @version:
 * @Author: JinYiGao
 * @Date: 2021-08-27 22:54:10
 * @LastEditors: JinYiGao
 * @LastEditTime: 2021-08-27 22:54:10
 */
#pragma once

#include <fstream>
#include <iostream>
#include <sstream>

#include <glad/glad.h>

#include <Eigen/Eigen>

using std::string;

class Shader {
public:
    GLuint programId; // 着色器程序引用ID

public:
    Shader();
    ~Shader();

    bool createFromSource(const char *vertShaderSource, const char *fragShaderSource); // 根据shader源码创建
    bool createFromFileName(const char *vertShaderFileName,
                            const char *fragShaderFileName); // 根据文件创建shaderprogram

    // 绑定着色器
    bool bind();
    // 解绑着色器
    void unbind();

    // set uniformValue
    void setBool(const std::string &name, bool value) const;
    void setInt(const std::string &name, int value) const;
    void setFloat(const std::string &name, float value) const;
    void setVec2(const std::string &name, const Eigen::Vector2f &value) const;
    void setVec2(const std::string &name, float x, float y) const;
    void setVec3(const std::string &name, const Eigen::Vector3f &value) const;
    void setVec3(const std::string &name, float x, float y, float z) const;
    void setVec4(const std::string &name, const Eigen::Vector4f &value) const;
    void setVec4(const std::string &name, float x, float y, float z, float w);
    void setMat2(const std::string &name, const Eigen::Matrix2f &mat) const;
    void setMat3(const std::string &name, const Eigen::Matrix3f &mat) const;
    void setMat4(const std::string &name, const Eigen::Matrix4f &mat) const;
};